#include <stdio.h>
const int N = 110;

int main()
{
    int a[N];
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        a[i] = i + 1;
    }
    //
    int cnt = 0;
    int i = 0;
    int tmp = n;
    while (--tmp)
    {
        cnt = 0;
        for (;; i++)
        {
            if (a[i % n] == 0)
                continue;
            cnt++;

            if (cnt == m)
            {
                printf("%d ", a[i % n]);
                a[i % n] = 0;
                i++;
                break;
            }
        }
    }
    printf("%d",a[i%n]);

}
